package com.konsung.util;

/**
 * 创建者     tangchao
 * 创建时间   2018/4/12 0012 上午 10:39
 * 描述       $
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述   $
 */

public class ClickUtils {
    // 两次点击按钮之间的点击间隔不能少于1000毫秒
    private static final int MIN_CLICK_DELAY_TIME = 1000;
    private static final int TWO_CLICK_DELAY_TIME = 2000;
    private static long lastClickTime;

    /**
     * 按钮防抖功能
     *
     * @return the boolean
     */
    public static boolean isFastClick() {
        boolean flag = false;
        long curClickTime = System.currentTimeMillis();
        if ((curClickTime - lastClickTime) >= MIN_CLICK_DELAY_TIME) {
            flag = true;
        }
        lastClickTime = curClickTime;
        return flag;
    }

    /**
     * 按钮防抖功能
     *
     * @return the boolean
     */
    public static boolean isFastClickTwo() {
        boolean flag = false;
        long curClickTime = System.currentTimeMillis();
        if ((curClickTime - lastClickTime) >= TWO_CLICK_DELAY_TIME) {
            flag = true;
        }
        lastClickTime = curClickTime;
        return flag;
    }



    /**
     * 检验体重是否超限
     *
     * @param weight 体重
     * @return 是否超限
     */
    public static boolean checkWeight(String weight) {
        boolean check = false;
        float data = Float.valueOf(weight);
        if (data > 635f) {
            //超出吉尼斯最大体重，不符合标准
            check = true;
        }
        return check;
    }
}
